Completed
Push — master ( e65836...fa4d5c )
by Mathieu
12s queued 10s
created

Project   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 59
dl 0
loc 68
rs 10
c 0
b 0
f 0
wmc 8

8 Functions

Rating   Name   Duplication   Size   Complexity  
A getInvoiceUnit 0 4 1
A update 0 11 1
A getDayDuration 0 4 1
A getCustomer 0 3 1
A getCreatedAt 0 3 1
A getFullName 0 3 1
A getName 0 3 1
A getId 0 3 1
1
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm';
2
import { Customer } from '../Customer/Customer.entity';
3
4
export enum InvoiceUnits {
5
  DAY = 'day',
6
  HOUR = 'hour'
7
}
8
9
@Entity()
10
export class Project {
11
  @PrimaryGeneratedColumn('uuid')
12
  private id: string;
13
14
  @Column({type: 'varchar', nullable: false})
15
  private name: string;
16
17
  @Column({type: 'integer', nullable: false, default: 420, comment: 'Stored in minutes'})
18
  private dayDuration: number;
19
20
  @Column('enum', {enum: InvoiceUnits, nullable: false})
21
  private invoiceUnit: InvoiceUnits;
22
23
  @Column({type: 'timestamp', default: () => 'CURRENT_TIMESTAMP'})
24
  private createdAt: Date;
25
26
  @ManyToOne(type => Customer, {nullable: false, onDelete: 'CASCADE'})
27
  private customer: Customer;
28
29
  constructor(name: string, dayDuration: number, invoiceUnit: InvoiceUnits, customer: Customer) {
30
    this.name = name;
31
    this.dayDuration = dayDuration;
32
    this.invoiceUnit = invoiceUnit;
33
    this.customer = customer;
34
  }
35
36
  public getId(): string {
37
    return this.id;
38
  }
39
40
  public getName(): string {
41
    return this.name;
42
  }
43
44
  public getDayDuration(): number
45
  {
46
    return this.dayDuration;
47
  }
48
49
  public getInvoiceUnit(): InvoiceUnits
50
  {
51
    return this.invoiceUnit;
52
  }
53
54
  public getCreatedAt(): Date {
55
    return this.createdAt;
56
  }
57
58
  public getCustomer(): Customer {
59
    return this.customer;
60
  }
61
62
  public getFullName(): string {
63
    return `[${this.customer.getName()}] ${this.getName()}`;
64
  }
65
66
  public update(
67
    customer: Customer,
68
    dayDuration: number,
69
    invoiceUnit: InvoiceUnits,
70
    name: string
71
  ): void {
72
    this.customer = customer;
73
    this.dayDuration = dayDuration;
74
    this.invoiceUnit = invoiceUnit;
75
    this.name = name;
76
  }
77
}
78